import { RandomEventBase } from "./Sheets"
import { SheetManager } from "../../ccc3-framework-core/framework/modules/sheetManager";
export class RandomEvent extends RandomEventBase {
  //id索引
  public static get(id: any) {
    if ((this as any)[id]) return (this as any)[id];
    return SheetManager.get("RandomEvent", id, RandomEvent);
  }

  public static getAll() {
    return SheetManager.getAllSheets("RandomEvent", RandomEvent);
  }

  //根据eventType随机获取一个事件
  public static getRandomEventByEventType(eventType: number) {
    let eventList = this.getAll().filter(item => item.eventType == eventType);
    let randomIndex = Math.floor(Math.random() * eventList.length);
    return eventList[randomIndex];
  }
}